import store from '@/store';
import router from '@/router';

const whiteList = [];

// 全局路由前置守卫==>初始化的时候和每次路由切换之前被调用
router.beforeEach((to, from, next) => {
  try {
    let token = store.getters.token;
    if (!whiteList.includes(to.path) && !token) {
      next('/login');
      return;
    }
  } catch (error) {
    console.log(error);
  }
  next();
});

// 全局路由后置守卫==>初始化的时候和每次路由切换之后被调用
// router.afterEach((to, from) => {
//   console.log(to, from);
// });
